#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1005;

int n, m;
int a[N][N];
int solve(int a[N]) {
  stack<int> st;
  int ans = 0;
  rep(i, 1, m) {
    while (st.size() && a[st.top()] >= a[i]) {
      int h = a[st.top()];
      st.pop();
      int j = st.size() ? st.top() + 1 : 1;
      int w = i - j;
      ans = max(ans, h * w);
    }
    st.push(i);
  }
  while (st.size()) {
    int h = a[st.top()];
    st.pop();
    int j = st.size() ? st.top() + 1 : 1;
    int w = m + 1 - j;
    ans = max(ans, h * w);
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  rep(i, 1, n) rep(j, 1, m) {
    char c;
    cin >> c;
    a[i][j] = c == 'F';
  }
  int ans = 0;
  rep(i, 1, n) {
    rep(j, 1, m) if (a[i][j]) a[i][j] += a[i - 1][j];
    ans = max(ans, solve(a[i]));
  }
  cout << ans * 3;
  return 0;
}